package com.geek.exception;

/**
 * @author wbw
 * @data 2024/06/14 16:49
 **/
public class InventoryManager {
    private int stock;
    public InventoryManager(int stock){
        this.stock = stock;
    }
    public void checkStock(int requiredQuantity) throws StockException {
        if (requiredQuantity > stock) {
            // 库存不足，抛出异常
            throw new StockException("库存不足，无法完成交易。当前库存：" + stock + "，所需数量：" + requiredQuantity);
        }
    }
}
